﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

namespace Project_1.Models
{
    public class Message
    {
        public int Id { get; set; }
	    public string Title { get; set; }
	    public string Content { get; set; }
	    public string Sender { get; set; }
	    public string Receiver { get; set; }
	    public DateTime SentTime { get; set; }
        public bool Read { get; set; }
    }

    public class MessageConfiguration : EntityTypeConfiguration<Message>
    {
        public MessageConfiguration() : base()
        {
            HasKey(p => p.Id);
            Property(p => p.Id).
                HasColumnName("Id").
                HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).
                IsRequired();
            Property(p => p.Title).
                HasColumnName("Title").
                IsRequired();
            Property(p => p.Content).
                HasColumnName("Content").
                IsRequired();
            Property(p => p.Sender).
                HasColumnName("Sender").
                IsRequired();
            Property(p => p.Receiver).
                HasColumnName("Receiver").
                IsRequired();
            Property(p => p.SentTime).
                HasColumnName("SentTime").
                IsRequired();
            Property(p => p.Read).
                HasColumnName("Read").
                IsRequired();
            ToTable("Messages");
        }
    }
}